#include <bits/stdc++.h>

#include <atcoder/all>
#define LL long long
using namespace std;
using namespace atcoder;

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  vector<modint998244353> fac, inv_fac;
  vector<int> pre_sum[10], suf_sum[10];
  string s;
  int n;

  cin >> s;
  n = s.size();
  s = "#" + s;
  fac.resize(n + 1);
  inv_fac.resize(n + 1);
  fac[0] = 1;
  for (int i = 1; i <= n; i++) {
    fac[i] = fac[i - 1] * i;
  }
  inv_fac[n] = fac[n].inv();
  for (int i = n - 1; i >= 0; i--) {
    inv_fac[i] = inv_fac[i + 1] * (i + 1);
  }
  for (int i = 0; i < 10; i++) {
    pre_sum[i].resize(n + 1, 0);
    suf_sum[i].resize(n + 1, 0);
  }

  modint998244353 ans;
  for (int i = 1; i <= n; i++) {
    for (int j = 0; j < 10; j++) {
      pre_sum[j][i] = pre_sum[j][i - 1];
    }
    pre_sum[s[i] - '0'][i]++;
  }
  suf_sum[s[n] - '0'][n]++;
  for (int i = n - 1; i > 0; i--) {
    for (int j = 0; j < 10; j++) {
      suf_sum[j][i] = suf_sum[j][i + 1];
    }
    suf_sum[s[i] - '0'][i]++;
  }

  for (int i = 1; i <= n; i++) {
    if (s[i] == '9') {
      continue;
    }
    modint998244353 C = 0;
    int a = pre_sum[s[i] - '0'][i - 1] + suf_sum[s[i] - '0' + 1][i], b = suf_sum[s[i] - '0' + 1][i] - 1;

    if (b >= 0) {
      C = fac[a] * inv_fac[b] * inv_fac[a - b];
    }
    ans += C;
  }
  cout << ans.val() << "\n";
  return 0;
}
